import request from '@/utils/request'
import type { Result } from '@/types/api'

// 设备使用统计
export interface EquipmentUsage {
  totalEquipment: number
  inUseCount: number
  maintenanceCount: number
  idleCount: number
  usageRate: number
  categoryUsage: Array<{
    categoryName: string
    count: number
    usageRate: number
  }>
}

// 收入统计
export interface IncomeStat {
  totalIncome: number
  leaseIncome: number
  maintenanceIncome: number
  dailyIncome: Array<{
    date: string
    amount: number
  }>
  categoryIncome: Array<{
    categoryName: string
    amount: number
  }>
}

// 维修统计
export interface MaintenanceStat {
  totalOrders: number
  completedOrders: number
  avgRepairTime: number
  totalRepairFee: number
  equipmentRanking: Array<{
    equipmentName: string
    faultCount: number
    repairFee: number
  }>
}

// 获取设备使用统计
export function getEquipmentUsage(params: { startDate: string; endDate: string }) {
  return request.get<Result<EquipmentUsage>>('/admin/statistics/equipmentUsage', { params })
}

// 获取收入统计
export function getIncomeStat(params: { startDate: string; endDate: string }) {
  return request.get<Result<IncomeStat>>('/admin/statistics/income', { params })
}

// 获取维修统计
export function getMaintenanceStat(params: { startDate: string; endDate: string }) {
  return request.get<Result<MaintenanceStat>>('/admin/statistics/maintenance', { params })
} 